package org.example.domain;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @FileName Result
 * @Description
 * @Author coderfun
 * @selfDesc coding in fun
 * @date 2024-11-02
 **/
@AllArgsConstructor
@NoArgsConstructor
@Data
public class Result<T> {
    private Integer code;
    private T data;
    private String msg;

    public static <T> Result<T> success(){
        return new Result<>(200,null,"success");
    }
    public static <T> Result<T> success(T data){
        return new Result<>(200,data,"success");
    }
    public static <T> Result<T> success(T data,String msg){
        return new Result<>(200,data,msg);
    }
    public static <T> Result<T> success(String msg){
        return new Result<>(200,null,msg);
    }
    public static <T> Result<T> fail(Integer code,String msg){
        return new Result<>(code,null,msg);
    }
    public static <T> Result<T> fail(){
        return new Result<>(405,null,"fail");
    }
    public static <T> Result<T> fail(String msg){
        return new Result<>(411,null,msg);
    }
}
